# -*- coding: utf-8 -*-
# @Time    : 2019-09-11 11:38
# @Author  : Jaedong
# @Version : 3.6
# @File    : Main.py
# @Software: PyCharm

import Utiles as utile
import Force

# # 下面是两个用于测试的数独
# input = [[7, 2, 0, 5, 0, 0, 0, 0, 0],
#          [5, 0, 0, 0, 4, 0, 6, 0, 0],
#          [0, 8, 0, 1, 0, 0, 0, 0, 0],
#          [0, 0, 0, 0, 0, 3, 0, 0, 9],
#          [0, 4, 3, 0, 0, 0, 0, 0, 0],
#          [0, 0, 0, 0, 0, 6, 0, 5, 0],
#          [0, 0, 1, 6, 0, 0, 4, 0, 7],
#          [0, 0, 0, 0, 0, 9, 0, 0, 0],
#          [0, 9, 0, 0, 0, 0, 0, 0, 0]]

input = [[0, 7, 0, 4, 6, 3, 0, 0, 8],
         [0, 8, 0, 2, 0, 0, 3, 0, 0],
         [0, 3, 0, 8, 0, 0, 0, 9, 0],
         [4, 0, 2, 5, 8, 6, 0, 0, 3],
         [0, 0, 0, 9, 2, 0, 8, 0, 4],
         [8, 0, 0, 0, 3, 4, 0, 0, 0],
         [0, 2, 0, 0, 5, 8, 0, 0, 0],
         [0, 6, 0, 3, 4, 0, 2, 8, 5],
         [5, 4, 8, 6, 0, 2, 0, 3, 7]]

# 入口函数
if __name__ == "__main__":
    utile.print_grid(input)
    print("请等待，正在破解数独... >>>>>>>>")

    output = Force.try_fill(input)

    if output != None:
        print("破解完成，该数独的一个解为：")
        utile.print_grid(output)
    else:
        print("很抱歉，我没有解出来该数独的解！")